package com.niit.agricstore.controller;

import com.niit.agricstore.util.CacheTemplateUtil;
import com.niit.agricstore.util.Result;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/home")
public class HomeController {
    @GetMapping("/homeCarousel")
    //获取轮播图
    public Result homeCarousel() {
        HashMap<String, String> goodsImgHash = CacheTemplateUtil.getGoodsImgHash();
        List list = new ArrayList();
        for (String s : goodsImgHash.keySet()) {
            Map<String, String> stringHashMap = new HashMap<>();
            stringHashMap.put("key", s);
            stringHashMap.put("value", goodsImgHash.get(s));
            list.add(stringHashMap);
        }
        return Result.success(list);
    }
}
